/**
 * 
 * axios post请求默认提交的是JSON,如果需要提交 application/x-www-form-urlencoded =>
 * 1、引入 import queryString from 'querystring';
 * 2、参数 queryString.stringify(para)
 * [参考](https://github.com/mzabriskie/axios#using-applicationx-www-form-urlencoded-format)
 * 
 * 
 * [API地址](http://59.107.26.181:8088/swagger-ui.html#!/private-product-controller/addUsingPOST)
 */

import axios from 'axios';
import queryString from 'querystring';

let api = {
    getNoticeList: '/api-active/v1/api/announcement/backend/list', //列表 
    postCreatNewNotice: '/api-active/v1/api/announcement/backend/create', //新建公告
    getNoticeDetail: '/api-active/v1/api/announcement/backend/detal/', //查询公告详情
    postPublishNotice: '/api-active/v1/api/announcement/backend/push', //推送公告
    postUpdatehNotice: '/api-active/v1/api/announcement/backend/update', //更新公告
}

const postCreatNewNotice = (param) => {
    return axios.post(api.postCreatNewNotice, param)
}

const postPublishNotice = (param) => {
    return axios.post(api.postPublishNotice, queryString.stringify(param))
}

const postUpdatehNotice = (param) => {
    return axios.post(api.postUpdatehNotice, param)
}

const getNoticeList = (params) => { return axios.get(api.getNoticeList, { params: params }) }

const getNoticeDetail = (id) => { return axios.get(api.getNoticeDetail + id) }



export {
    api,
    getNoticeList,
    postCreatNewNotice,
    getNoticeDetail,
    postPublishNotice,
    postUpdatehNotice,
}